﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

using System;
using System.Windows;
using Microsoft.Phone.Controls;

namespace FeatureOverview.Features.Sensors
{
    public partial class Vibration : PhoneApplicationPage
    {
        public Vibration()
        {
            InitializeComponent();
        }

        private void _vibrate_Click(object sender, RoutedEventArgs e)
        {
            Vibrate();
        }

        private void Vibrate()
        {
            if (Microsoft.Devices.Environment.DeviceType
                 == Microsoft.Devices.DeviceType.Emulator)
            {
                MessageBox.Show("Sorry, I'm just an app running in a poor emulator");
                return;
            }

            Microsoft.Devices.VibrateController vc = Microsoft.Devices.VibrateController.Default;
            vc.Start(new TimeSpan(0, 0, 5));
        }

        private void _vibrateStop_Click(object sender, RoutedEventArgs e)
        {
            if (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator)
            {
                MessageBox.Show("Sorry, I'm just an app running in a poor emulator");
                return;
            }

            Microsoft.Devices.VibrateController vc = Microsoft.Devices.VibrateController.Default;
            vc.Stop();
        }
    }
}